<template>
  <div
    class="container"
    :style="{
      transform: mainStoreIns.menuOpen ? 'translateX(300px)' : 'translateX(0)',
    }"
  >
    <menuComp v-show="mainStoreIns.menuOpen" v-bind="menuCompProp" />
    <div
      class="content"
      :class="{
        content_mask: mainStoreIns.menuOpen,
      }"
      @click="maskClick"
    >
      <header class="home_header">
        <div class="lg common_text_decoration" @click.stop="openMenu('lang')">
          {{ $t('message.lang') }}
        </div>
        <div class="des">{{ $t('message.topT') }}</div>
        <div class="links">
          <span
            v-for="(o, i) in links"
            :key="i"
            class="icon iconfont link_item"
            :class="o.icon"
          ></span>
        </div>
      </header>
      <navComp @toOpenMenu="openMenu" />
      <mainComp />
    </div>
    <div class="mask"></div>
  </div>
</template>

<script setup lang="ts">
import { links } from './config';
import navComp from './nav.vue';
import mainComp from './mainContent.vue';
import menuComp from './menu.vue';
import { mainStore } from '@/stores/main';
import { reactive } from 'vue';

const mainStoreIns = mainStore();

const maskClick = () => {
  mainStoreIns.menuOpen && mainStoreIns.changeMenuStatus();
};
const menuCompProp = reactive({
  type: 'lang',
});
const openMenu = (type = 'lang') => {
  console.log(type);
  menuCompProp.type = type;
  mainStoreIns.changeMenuStatus();
};
</script>

<style lang="scss" scoped>
.container {
  position: relative;
  width: 100%;
  display: flex;
  transition: all 0.3s ease-out;
}
.content {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}
.content_mask {
  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background-color: rgba(0, 0, 0, 0.4);
  }
}
.home_header {
  height: 84px;
  line-height: 84px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid $main-border-color;

  .lg {
    height: 24px;
    line-height: 24px;
    margin: 0 20px;
    cursor: pointer;
    @include baseline(transparent, 100%);

    &::after {
      background-repeat: no-repeat;
      background-image: linear-gradient(
        to right,
        black 45%,
        rgba(32, 33, 33, 0.3) 55%
      );
      background-size: 220% 100%;
      background-position: 100% 100%;
      transition: 0.3s ease-out;
    }

    &:hover {
      &::after {
        background-position: 0% 100%;
      }
    }
  }

  .des {
    flex: 1;
    text-align: center;
    font-size: 20px;
  }

  .links {
    padding-right: 14px;
  }

  .link_item {
    color: $primary-font-color;
    padding: 0 5px;
    font-size: 20px;
    cursor: pointer;
    @include hoverReduceOp(0.6);
  }
}
</style>
